package com.jzr.board.controller.api;

import com.jzr.board.db1.dto.ShiftPlanDto;
import com.jzr.board.db1.service.TShiftPlanService;
import com.jzr.board.db1.vo.ShiftPlanVo;
import com.jzr.common.entity.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@Api(tags = "排班接口")
@RestController
@RequestMapping("/api/shiftPlan")
public class ShiftPlanController {
    @Autowired
    private TShiftPlanService shiftPlanService;

    @ApiOperation("获取今天排班列表")
    @GetMapping("/todayList")
    public Result<List<ShiftPlanVo>> todayList(String deptCode){
        ShiftPlanDto record = new ShiftPlanDto();
        record.setDeptCode(deptCode);
        LocalDate today = LocalDate.now();
        if(record.getStaffType() == null){
            record.setStaffType(0); //护士
        }
        record.setY(today.getYear());
        record.setM(today.getMonthValue());
        record.setD(today.getDayOfMonth());

        List<ShiftPlanVo> list = shiftPlanService.list(record);
        return Result.success("成功",list);
    }

}
